package org.planaz.campusvoting.common.enums;

import java.util.HashMap;
import java.util.Map;

public enum EmailTypeEnum {
    REGISTER("register","注册"),
    RESET_PASSWORD("reset_password","重置密码"),
    RESET_EMAIL("reset_email","重置邮箱"),
    LOGIN("login","登录"),
    OTHER("other", "其他");

    private final String code;
    private final String name;
    EmailTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /** 静态化一个枚举集合，状态码作为对应枚举的索引 */
    static Map<String,EmailTypeEnum> enumMap= new HashMap<>();
    // 初始化枚举集合
    static {
        for (EmailTypeEnum key : EmailTypeEnum.values()) {
            enumMap.put(key.getCode(), key);
        }
    }

    public static EmailTypeEnum getEnum(String code) {
        return enumMap.get(code);
    }

}
